<?php
    header("Content-type: text/html; charset=utf-8");
    include_once '../mysqldb/MySqlHelper.php';
    $MySqlHelper = new MySqlHelper();
    $LoginName = $_POST['UserName'];
    $LoginPwd=$_POST['LoginPwd'];
    
    $sql='select ID,LoginName,LoginPwd,TrueName from ManagerList where Status = true and LoginName = \''.$LoginName.'\'';
    //echo $MySqlHelper->Exists($sql);
    if($MySqlHelper->Exists($sql))
    {
    	$row=$MySqlHelper->GetRow($sql);

    	if($row['LoginPwd']==md5($LoginPwd))
    	{
    		session_start();
    		$_SESSION['TrueName']=$row['TrueName'];
    		$_SESSION['ID']=$row['ID'];
    		echo '<script type="text/javascript">window.location.href="index.php";</script>';
    	}
    	else {
    		echo '<script type="text/javascript">alert("密码错误！");history.go(-1);</script>';
    	}
    }
    else 
    {
    	echo '<script type="text/javascript">alert("用户名错误！");history.go(-1);</script>';
    }